<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body ,html{
            margin: 0;
            padding: 0; /* 去除默认的内边距 */
            resize: both;
            width: 100%;
            height: 100%;
        }
        #linechart{
            width: 100%;
            height: 100%;
            resize: both;
            overflow: auto;
        }
    </style>
</head>
<body>
<script src="./lib/echarts.js"></script>
<div id="linechart"></div>
<script>
    var myChart = echarts.init(document.getElementById('linechart'), null, {renderer: 'svg'});
    var option = {
        title: {
            text: 'line chart'
        },
        xAxis: {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: [820, 932, 901, 934, 1290, 1330, 1320],
                type: 'line',
                smooth: true
            }
        ]
    };
    myChart.setOption(option);
    // 监听窗口大小变化
    function resizeChart() {
        myChart.resize();
    }
    window.addEventListener('resize', resizeChart);
    //赋值函数
    function setData(data){
        option.series[0].data = data;
        myChart.setOption(option);
    }
</script>
</body>
</html>